package com.kaili.quartz.controller;



import com.kaili.quartz.service.SchedulerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/quartz")
public class QuartzClusterController {

    @Autowired
    private SchedulerService schedule;

    /**
     *
     * @param cron
     * @return
     */
    @GetMapping("/modify")
    public String modifyStartQuartz(@RequestParam("cron") String cron){
        try {
            schedule.schedule("testJobTrigger", "DEFAULT", cron);
        } catch (Exception e) {
            return "Failed";
        }
        return "Successful";
    }
}